/*
 * @Author: linzaifei 1609781601@qq.com
 * @Date: 2025-05-12 08:38:02
 * @LastEditors: linzaifei 1609781601@qq.com
 * @LastEditTime: 2025-08-15 14:25:32
 * @FilePath: /amap-web-vr/src/stores/search.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
// import {placeSearch,setCenter } from '@/utils/map';

  
interface ZFPoisReslut {
    adcode: string
    address: string
    adname: string
    citycode: string
    cityname: string
    discount: boolean
    distance: number
    email: string
    entr_location: any
    exit_location: any
    groupbuy: boolean
    id: string
    index: number
    indoor_map: boolean
    location: any
    name: string
    pcode: string
    photos: any[]
    pname: string
    postcode: string
    shopinfo: string
    tel: string
    type: string
    website: string
    _idx: number
}

export const useSearchStore = defineStore('search', {

    state: () => {
        return {
            state:'',
            links:[] as ZFPoisReslut[]
        }
    },
    actions: {
        querySearchAsync(queryString: string, cb: (arg: any) => void){
            console.log("queryString",queryString)
            if (queryString === '') {
                cb([])
                return
            }
            // placeSearch(queryString).then((results)=>{
            //     let pois = (results as any).poiList.pois as ZFPoisReslut[];
            //     let list = pois.map((item)=>{
            //         return {
            //             value: item.name,  // 必须包含value属性
            //             ...item            // 保留原始数据用于后续处理
            //         }
            //     });
            //     cb(list)
            //    }).catch(e=>{
            //     console.log("搜索出错:", e)  
            //     cb([])
            //    });  
          },
          handleSelect(item: Record<string, any>){
            console.log("item",item)
            // setCenter([item.location.lng,item.location.lat])
          }
    },   
      
})
